function t(a) {
  console.log('oooooo', o);
  console.log(getApp());
    // o.showLoading("正在加载数据"), 
    wx.request({
        url: i.globalData.host + "/lotto/v1/sponsor/daily",
        method: "GET",
        dataType: "json",
        data: {
            access_token: o.getToken() || ""
        },
        success: function(e) {
            if (o.hideLoading(), -500 != e.data.sta) if (0 == e.data.sta) {
                var s = e.data.data.lotto;
                s.length >= 10 && !0;
                for (var i = 0; i < s.length; i++) s[i].date = o.formatDate(1e3 * s[i].date, "MM月dd日 HH:mm");
                a.setData({
                    lottoList: s,
                    subscribe: e.data.data.subscribe
                });
            } else o.showFailedToast("数据加载失败", e.data.msg); else o.login(function() {
                t(a), a.setData({
                    hasUserInfo: !0
                });
            }, function() {
                a.setData({
                    hasUserInfo: !1
                });
            });
        },
        fail: function(t) {
            o.showFailedToast("数据加载失败");
        }
    });
}

function a(t) {
    o.showLoading("正在保存数据");
    var e = t.data.phone, s = t.data.code;
    s = s ? parseInt(s) : "", s = 1 == t.data.isDev ? 9999999 : s;
    var n = {
        access_token: wx.getStorageSync("accessToken"),
        subscribe: t.data.subscribe
    };
    e != t.data.oldPhone && (n.phone = e), wx.request({
        url: i.globalData.host + "/lotto/v1/client_info",
        data: n,
        method: "POST",
        success: function(e) {
            o.hideLoading(), -500 != e.data.sta ? 0 != e.data.sta ? (o.showFailedToast("设置失败", e.data.msg), 
            t.setData({
                subscribe: !t.data.subscribe
            })) : o.showModelTips("你可以在个人中心里管理订阅状态。", "订阅成功") : o.loginAPI(function() {
                a(t);
            });
        },
        fail: function(t) {
            o.hideLoading(), o.showFailedToast("网络请求超时，" + t.errMsg);
        }
    });
}

var e = Object.assign || function(t) {
    for (var a = 1; a < arguments.length; a++) {
        var e = arguments[a];
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
    return t;
}, o = require("../../utils/util.js"), s = require("../../tmp/tmp.js"), i = getApp();

Page({
    data: {
        enrollList: null,
        contactUserInfo: '{ "nickName": "' + o.getStorage("userInfo").nickName + '", "avatarUrl": "' + o.getStorage("userInfo").avatarUrl + '" }',
        adId: "9ecbcfe2c3d40853450bb2d3d330c6bd",
        tipsClick: !!o.getStorage("subscribeTipsClick")
    },
    onLoad: function(a) {
        var e = decodeURIComponent(a.scene || "");
        if (e.length > 7) wx.navigateTo({
            url: "/pages/detail/detail?lid=" + e
        }); else if (a.lid) wx.navigateTo({
            url: "/pages/detail/detail?lid=" + a.lid
        }); else {
            var i = this;
            s.wxLogin(this, function() {
                var a = wx.getStorageSync("userInfo");
                i.setData({
                    avatar: a.avatarUrl,
                    nickname: a.nickName
                }), t(i);
            }), o.adShow({
                ad_id: "open_index",
                desc: "抽奖首页打开统计"
            }, a.from || ""), s.ads(this, this.data.adId, "dailylotto");
        }
    },
    onShow: function() {
        this.setData({
            page: 1
        }), t(this), this.setData({
            contactUserInfo: '{ "nickName": "' + o.getStorage("userInfo").nickName + '", "avatarUrl": "' + o.getStorage("userInfo").avatarUrl + '" }'
        });
    },
    onHide: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return e({
            title: "每日精选福利，海量奖品免费拿"
        }, {
            imageUrl: "https://cdn-xcxcustom.weiyoubot.cn/20180727/8f738700913ab760b2028b17eee32392.jpg"
        }, {
            path: "/pages/dailylotto/dailylotto"
        });
    },
    myJoin: function() {
        o.buttonClicked(this), wx.navigateTo({
            url: "/pages/myjoin/myjoin"
        });
    },
    toSponsor: function() {
        wx.navigateTo({
            url: "/pages/sponsor/sponsor"
        });
    },
    toDetail: function(t) {
        o.buttonClicked(this);
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/pages/detail/detail?lid=" + a
        });
    },
    postFormId: function(t) {
        o.postFormId(t.detail.formId);
    },
    closeSubscribeTips: function() {
        this.setData({
            tipsClick: !0
        }), o.setStorage("subscribeTipsClick", 1);
    },
    subscribe: function() {
        this.setData({
            subscribe: 1
        }), a(this);
    }
});